Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit eb16e5f9a01c1d05cb0100f6655e331c64869824


Parents : 1f008fb
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-07-18T12:00:29+02:00

Provide approximate radio horizon even if altitude is 0

Changes

1 files changed, 48 insertions(+), 66 deletions(-)


Diff

diff --git a/sbapp/sideband/sense.py b/sbapp/sideband/sense.py
index 52484abc..94d4dabe 100644
--- a/sbapp/sideband/sense.py
+++ b/sbapp/sideband/sense.py
@@ -801,10 +801,8 @@ class Location(Sensor):
self._last_update = time.time()
def get_aamsl(self):
- if self.data["altitude"] == None or self.data["latitude"] == None or self.data["longitude"] == None:
- return None
- else:
- return altitude_to_aamsl(self.data["altitude"], self.data["latitude"], self.data["longitude"])
+ if self.data["altitude"] == None or self.data["latitude"] == None or self.data["longitude"] == None: return None
+ else: return altitude_to_aamsl(self.data["altitude"], self.data["latitude"], self.data["longitude"])
def set_update_time(self, update_time):
self._synthesized_updates = True
@@ -860,58 +858,49 @@ class Location(Sensor):
self.accuracy = 0
if self.accuracy != None and self.accuracy <= self._accuracy_target:
- self.data = {
- "latitude": round(self.latitude, 6),
- "longitude": round(self.longitude, 6),
- "altitude": round(self.altitude, 2),
- "speed": round(self.speed, 2),
- "bearing": round(self.bearing, 2),
- "accuracy": round(self.accuracy, 2),
- "last_update": int(self._last_update),
- }
+ self.data = { "latitude": round(self.latitude, 6),
+ "longitude": round(self.longitude, 6),
+ "altitude": round(self.altitude, 2),
+ "speed": round(self.speed, 2),
+ "bearing": round(self.bearing, 2),
+ "accuracy": round(self.accuracy, 2),
+ "last_update": int(self._last_update) }
- except:
- self.data = None
+ except: self.data = None
def pack(self):
d = self.data
- if d == None:
- return None
+ if d == None: return None
else:
try:
- return [
- struct.pack("!i", int(round(d["latitude"], 6)*1e6)),
- struct.pack("!i", int(round(d["longitude"], 6)*1e6)),
- struct.pack("!i", int(round(d["altitude"], 2)*1e2)),
- struct.pack("!I", int(round(d["speed"], 2)*1e2)),
- struct.pack("!i", int(round(d["bearing"], 2)*1e2)),
- struct.pack("!H", int(round(d["accuracy"], 2)*1e2)),
- d["last_update"],
- ]
+ return [ struct.pack("!i", int(round(d["latitude"], 6)*1e6)),
+ struct.pack("!i", int(round(d["longitude"], 6)*1e6)),
+ struct.pack("!i", int(round(d["altitude"], 2)*1e2)),
+ struct.pack("!I", int(round(d["speed"], 2)*1e2)),
+ struct.pack("!i", int(round(d["bearing"], 2)*1e2)),
+ struct.pack("!H", int(round(d["accuracy"], 2)*1e2)),
+ d["last_update"] ]
+
except Exception as e:
RNS.log("An error occurred while packing location sensor data. The contained exception was: "+str(e), RNS.LOG_ERROR)
return None
def unpack(self, packed):
try:
- if packed == None:
- return None
+ if packed == None: return None
else:
- return {
- "latitude": struct.unpack("!i", packed[0])[0]/1e6,
- "longitude": struct.unpack("!i", packed[1])[0]/1e6,
- "altitude": struct.unpack("!i", packed[2])[0]/1e2,
- "speed": struct.unpack("!I", packed[3])[0]/1e2,
- "bearing": struct.unpack("!i", packed[4])[0]/1e2,
- "accuracy": struct.unpack("!H", packed[5])[0]/1e2,
- "last_update": packed[6],
- }
- except:
- return None
+ return { "latitude": struct.unpack("!i", packed[0])[0]/1e6,
+ "longitude": struct.unpack("!i", packed[1])[0]/1e6,
+ "altitude": struct.unpack("!i", packed[2])[0]/1e2,
+ "speed": struct.unpack("!I", packed[3])[0]/1e2,
+ "bearing": struct.unpack("!i", packed[4])[0]/1e2,
+ "accuracy": struct.unpack("!H", packed[5])[0]/1e2,
+ "last_update": packed[6] }
+
+ except: return None
def render(self, relative_to=None):
- if self.data == None:
- return None
+ if self.data == None: return None
obj_ath = None
obj_rh = None
@@ -920,23 +909,19 @@ class Location(Sensor):
aamsl = max(0, self.get_aamsl())
coords = (self.data["latitude"], self.data["longitude"], aamsl)
obj_ath = angle_to_horizon(coords)
- obj_rh = radio_horizon(aamsl)
+ obj_rh = radio_horizon(aamsl if aamsl > 0 else 1.0)
- rendered = {
- "icon": "map-marker",
- "name": "Location",
- "values": {
- "latitude": self.data["latitude"],
- "longitude": self.data["longitude"],
- "altitude": aamsl,
- "speed": self.data["speed"],
- "heading": self.data["bearing"],
- "accuracy": self.data["accuracy"],
- "updated": self.data["last_update"],
- "angle_to_horizon": obj_ath,
- "radio_horizon": obj_rh,
- },
- }
+ rendered = { "icon": "map-marker",
+ "name": "Location",
+ "values": { "latitude": self.data["latitude"],
+ "longitude": self.data["longitude"],
+ "altitude": aamsl,
+ "speed": self.data["speed"],
+ "heading": self.data["bearing"],
+ "accuracy": self.data["accuracy"],
+ "updated": self.data["last_update"],
+ "angle_to_horizon": obj_ath,
+ "radio_horizon": obj_rh } }
if relative_to != None and "location" in relative_to.sensors:
slat = self.data["latitude"]; slon = self.data["longitude"]
@@ -950,6 +935,7 @@ class Location(Sensor):
if lat != None and lon != None:
if alt == None: alt = 0
cs = (slat, slon, salt); cr = (lat, lon, alt)
+ hs = (slat, slon, salt if salt > 0 else 1.0); hr = (lat, lon, alt if alt > 0 else 1.0)
ed = euclidian_distance(cs, cr)
od = orthodromic_distance(cs, cr)
aa = azalt(cr, cs)
@@ -957,16 +943,12 @@ class Location(Sensor):
atd = aa[1]-ath
above_horizon = None
if aa[1] != None:
- if aa[1] > ath:
- above_horizon = True
- else:
- above_horizon = False
+ if aa[1] > ath: above_horizon = True
+ else: above_horizon = False
- srh = shared_radio_horizon(cs, cr)
- if salt != None and alt != None:
- dalt = salt-alt
- else:
- dalt = None
+ srh = shared_radio_horizon(hs, hr)
+ if salt != None and alt != None: dalt = salt-alt
+ else: dalt = None
rendered["distance"] = {"euclidian": ed, "orthodromic": od, "vertical": dalt}
rendered["azalt"] = {


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────